Skip to content

LTS 稳定版:长连接保活修复 + HarmonyOS 桌面托盘 + OHOS 核心/HAP CI - #160

Open
jerry-271828 wants to merge 31 commits into
xiaobaigroup:masterfrom
jerry-271828:pr/upstream-lts-stable
Open

LTS 稳定版:长连接保活修复 + HarmonyOS 桌面托盘 + OHOS 核心/HAP CI#160
jerry-271828 wants to merge 31 commits into
xiaobaigroup:masterfrom
jerry-271828:pr/upstream-lts-stable

Conversation

@jerry-271828

Copy link
Copy Markdown

概述

本 PR 将 LTS 稳定线(fix/lts-stable-long-connections)的修复与新功能合并到当前 master(基于 1fdc47eb rebase,共 31 个提交)。核心内容:

  • 长连接保活修复(锁屏 / 后台场景)
  • HarmonyOS 桌面系统托盘支持(新功能)
  • OHOS 核心(libflclash.so)与 HAP 的云构建 CI
  • LTS 稳定版构建与验证文档

修复 Fixes

提交 说明
fix: hold continuous task while proxy runs to survive screen lock 代理运行时保持 continuous task,避免锁屏后长连接被系统清理
fix: synchronize tray proxy selection state 托盘代理选中状态与主界面同步
fix: refresh proxy duration after tray restore 从托盘恢复代理后刷新代理运行时长
fix: stabilize HarmonyOS status bar lifecycle 稳定状态栏生命周期

新功能 Features

  • HarmonyOS 桌面托盘:新增 TrayManager / ClashTrayHolderAbility,支持桌面托盘展示与代理切换,详见 docs/tray-desktop-feature.md
  • OHOS 核心云构建.github/workflows/build-core.yml 交叉编译 libflclash.so(基于 -tlsmodegd 补丁工具链)
  • HAP 构建与发布.github/workflows/release-hap.yml 构建签名 HAP,并在版本 tag 上发布 unsigned release HAP

CI / 构建

  • xb_components 子模块 vendor 进仓库,便于云端构建
  • 新增 scripts/ci/ 下签名 / Profile 生成脚本,及 docs/ci-hap-signing.md

文档

  • 长连接生命周期审计:docs/lts-connection-lifecycle-audit.md
  • 同步 FIN 问题调查报告(INVESTIGATION / VERIFICATION 等)与 LTS 稳定版验证结果
  • LTS 稳定版构建说明:docs/lts-stable-build.md

合并说明

  • 上游历史重写后与本 fork 旧历史无共同祖先,已将提交 rebase 到当前 master 顶端(1fdc47eb),便于 review 与合并
  • rebase 期间 build-profile.json5 与上游新版本冲突,已按“保留上游 signingConfigs、仅应用本分支的注释清理”解决
  • 提交数较多(31 个),其中 CI 部分保留了试错迭代记录;如希望单次 squash 合并也完全兼容

jerry-271828 and others added 30 commits August 14, 2026 14:03
Builds the mihomo/gVisor backend with the OpenHarmony NDK and the OHOS-patched
Go toolchain (ohos_golang_go, -tlsmodegd), split into small independently-failing
steps. Uploads the arm64-v8a libflclash.so as an artifact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The parent repo pins core to 1638edba, which xfz347/Clash.Meta no longer has
("not our ref"), so git submodule update fails. Clone the default branch tips
instead to unblock the build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
release-branch.go1.24 of ohos_golang_go lacks the legacy -tlsmodegd flag.
Newer OHOS Go ports expose a real GOOS=ohos target that handles c-shared TLS
natively (and implies the `ohos` build tag), so build with that instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
go1.24 branch gates c-shared off for ohos and lacks -tlsmodegd. Revert to the
project's proven recipe (GOOS=linux + c-shared + -tlsmodegd) on release-branch.go1.23.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Only master, release-branch.go1.24, and go1.24_HiShell exist on the mirror;
go1.24 lacks -tlsmodegd. master is the only untried branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The public ohos_golang_go branches (go1.24/master) don't carry the -tlsmodegd
flag. Vendor moodyhunter/libHv2rayCore's 0001-support-tls-mode-gd.patch (adds the
flag + arm64 general-dynamic TLS via TLSDESC + musl c-shared runtime fixes) and
apply it to the go1.24 source before make.bash. Cache key now includes the patch
hash; link with -fuse-ld=lld per the reference recipe.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The OHOS go1.24 fork has its own edits in flags.go/base.flag.go and rejects the
patch. The patch targets upstream go1.24, so clone golang/go release-branch.go1.24
as the base (also drops the flaky gitcode dep); add --fuzz=3 fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Patch was cut against a specific go1.24.x; current release-branch HEAD drifted in
flags.go/base.flag.go. Full single-branch clone + git apply --3way merges past it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
moodyhunter/go-tls-mode-gd is go1.26.2 with tls-mode-gd already applied, so clone
and make.bash it directly instead of patching stock go and fighting point-release
drift. Removes the vendored patch and the apply step.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
xfz347/Clash.Meta default branch (main) has no go.mod; the OHOS-adapted code +
go.mod live on the `ohos` branch (same for likuai2010/gvisor-ohos). Pin both
clones to ohos and sanity-check go.mod presence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ohos-branch core needs deps not in flclash's pinned go.sum (go-ordered-map,
go-chi, sagernet/cors); -mod=mod lets go download + record them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
flclash's pinned go.mod pulls newer metacubex/quic-go+sing-quic than the ohos core
(API drift: component/tls vs metacubex/tls). Reinit a minimal go.mod + go mod tidy
so ./core's go.mod picks the matching (older) versions. GOTOOLCHAIN=local avoids
toolchain auto-download over the flaky network.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- docs/lts-connection-lifecycle-audit.md: call-graph audit proving public LTS
  has no automatic ClearConnections caller (destructive paths are manual or
  deliberate profile-switch/recovery only)
- docs/lts-stable-build.md: why this build replaces store V2
- version identity 1.7.4-lts-stable.1 (1007048), bundle unchanged
  (org.xbgroup.clashboxLTS, coexists with store V2)

No application-logic change.
- INVESTIGATION-2026-08-11-synchronized-fin.md: full root-cause record
  (store V2 ~180.5s UI-timer ClearConnections; mechanism, discriminators,
  exonerations, instrumented-build notes)
- latest_analysis.md: UI-execution-gated timer evidence (CPU-measured A/B/A)
- VERIFICATION-PROTOCOL.md: instrumented-build + V2 bisection protocol
- UPSTREAM-ISSUE-DRAFT.md: issue draft for xiaobaigroup/ClashBox
- LTS-BUILD-VALIDATION.md: install guide + on-device validation results
  (17min + 67min runs, zero automatic wipes, manual clear works)
Machine lock freezes/reclaims background app processes without a
continuous task, which kills the ClashBox UI process hosting the proxy
core and control plane (Codex and other proxied apps lose connectivity).

- Add ProxyKeepAliveService: auto-request TASK_KEEPING continuous task
  on proxy start (PC/2in1/tablet), release on proxy stop; idempotent,
  mutually exclusive with user-enabled keep-alive toggles; re-request
  with bounded retry when the system cancels the task.
- ClashViewModel: start keep-alive in StartVpn/ReStartVpn, stop in
  StopVpn, covering UI, widget-card and core-recovery paths.
- EntryAbility: subscribe to screen off/lock/on/unlock common events to
  reassert the continuous task around lock transitions; the existing 1s
  recovery loop then restarts the core if the VPN extension was killed.
Add release-hap.yml: rebuilds the native core at the pinned revisions,
packages the unsigned release HAP, and publishes it as a GitHub Release
(stable release on version-tag pushes, rolling nightly prerelease on
manual dispatch). Add !/.github to .gitignore so new workflow files are
trackable, and document the unsigned flow in docs/ci-hap-signing.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant